import collections
class FindSumPairs(object):

    def __init__(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        """
        self.c1 = collections.Counter(nums1)
        self.c2 = collections.Counter(nums2)
        self.nums2 = nums2


    def add(self, index, val):
        """
        :type index: int
        :type val: int
        :rtype: None
        """
        ori = self.nums2[index]
        self.c2[ori] -= 1
        self.c2[ori + val] += 1
        self.nums2[index] += val


    def count(self, tot):
        """
        :type tot: int
        :rtype: int
        """
        ans = 0
        for key in self.c1:
            ans += self.c1[key] * self.c2[tot - key]
        return ans
